package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmUserDTO;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "自媒体用户API",tags = "自媒体用户管理")
public class WmUserController {

    @Autowired
    WmUserService wmUserService;

    @ApiOperation(value = "根据用户名查询自媒体用户")
    @GetMapping("/api/v1/user/findByName/{name}")
    public ResponseResult<WmUser> findByName(@PathVariable String name){
        return wmUserService.findByName(name);
    }
    @ApiOperation(value = "保存自媒体用户")
    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> save(@RequestBody WmUser wmUser){
        return wmUserService.saveWmUser(wmUser);
    }

    @ApiOperation("自媒体用户登录接口")
    @PostMapping("/login/in")
    public ResponseResult login(@RequestBody WmUserDTO wmUserDTO){
        return wmUserService.login(wmUserDTO);
    }

}
